<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册 | 代码狂想</title>
    <style>
        /* 基础样式与野蛮主义风格 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            line-height: 1.6;
            background-color: #f0f0f0;
            color: #222;
            padding: 20px;
            max-width: 1200px;
            margin: 0 auto;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* 野蛮主义风格特点：粗体、不对称、高对比度 */
        header {
            background-color: #000;
            color: #fff;
            padding: 30px;
            margin-bottom: 30px;
            border: 5px solid #ff0066;
            position: relative;
        }

        h1 {
            font-size: 4rem;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: -2px;
            line-height: 1;
        }

        .tagline {
            font-size: 1.5rem;
            margin-top: 10px;
            color: #ff0066;
        }

        /* 导航样式 - 保持原始链接外观但放大 */
        nav {
            background-color: #ff0066;
            padding: 15px;
            margin-bottom: 30px;
        }

        nav ul {
            list-style: none;
            display: flex;
            flex-wrap: wrap;
        }

        nav li {
            margin-right: 30px;
        }

        nav a {
            color: #000;
            text-decoration: none;
            font-weight: bold;
            font-size: 1.2rem;
            padding: 5px 10px;
            background-color: #fff;
        }

        nav a:hover {
            background-color: #000;
            color: #fff;
        }

        /* 注册表单容器 */
        .register-container {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 30px;
            margin-bottom: 30px;
            flex: 1;
        }

        /* 注册表单样式 */
        .register-form {
            background-color: #fff;
            padding: 30px;
            border: 3px solid #000;
            box-shadow: 8px 8px 0 #000;
        }

        .register-form h2 {
            font-size: 2.5rem;
            margin-bottom: 20px;
            color: #ff0066;
            border-bottom: 2px solid #000;
            padding-bottom: 10px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
            font-size: 1.1rem;
        }

        .form-group input {
            width: 100%;
            padding: 12px;
            border: 2px solid #000;
            font-family: inherit;
            font-size: 1rem;
        }

        .form-group input:focus {
            outline: none;
            border-color: #ff0066;
            box-shadow: 0 0 0 2px rgba(255, 0, 102, 0.3);
        }

        .error-message {
            color: #ff0066;
            font-size: 0.9rem;
            margin-top: 5px;
            display: none;
        }

        .register-btn {
            background-color: #000;
            color: #fff;
            padding: 12px 20px;
            border: none;
            font-weight: bold;
            font-size: 1.1rem;
            cursor: pointer;
            width: 100%;
            margin-top: 10px;
        }

        .register-btn:hover {
            background-color: #ff0066;
        }

        .form-footer {
            margin-top: 20px;
            text-align: center;
        }

        .form-footer a {
            color: #ff0066;
            text-decoration: none;
            font-weight: bold;
        }

        .form-footer a:hover {
            text-decoration: underline;
        }

        /* 注册信息区域 */
        .register-info {
            background-color: #000;
            color: #fff;
            padding: 30px;
            border: 3px solid #ff0066;
        }

        .register-info h3 {
            font-size: 1.8rem;
            margin-bottom: 20px;
            color: #ff0066;
        }

        .register-info ul {
            margin-left: 20px;
            margin-bottom: 20px;
        }

        .register-info li {
            margin-bottom: 10px;
        }

        .feature-list {
            margin-top: 30px;
        }

        .feature-item {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }

        .feature-icon {
            background-color: #ff0066;
            color: #000;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-weight: bold;
        }

        /* 密码强度指示器 */
        .password-strength {
            margin-top: 10px;
            height: 10px;
            background-color: #f0f0f0;
            border: 2px solid #000;
        }

        .password-strength-bar {
            height: 100%;
            width: 0%;
            background-color: #ff0066;
            transition: width 0.3s;
        }

        .password-strength-text {
            font-size: 0.8rem;
            margin-top: 5px;
        }

        /* 野蛮主义风格的特色元素 */
        .brutal-element {
            height: 10px;
            background-color: #ff0066;
            margin: 20px 0;
        }

        footer {
            background-color: #000;
            color: #fff;
            padding: 30px;
            text-align: center;
            margin-top: 30px;
            border-top: 5px solid #ff0066;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .register-container {
                grid-template-columns: 1fr;
            }

            h1 {
                font-size: 2.5rem;
            }

            nav ul {
                flex-direction: column;
            }

            nav li {
                margin-bottom: 10px;
            }
        }
    </style>
</head>

<body>
    <header>
        <h1>代码狂想</h1>
        <p class="tagline">原始 · 直接 · 不妥协的技术思考</p>
    </header>

    <nav>
        <ul>
            <li><a href="index.html">首页</a></li>
            <li><a href="#">前端开发</a></li>
            <li><a href="#">后端架构</a></li>
            <li><a href="#">算法与数据结构</a></li>
            <li><a href="#">设计模式</a></li>
            <li><a href="about.html">关于</a></li>
            <li><a href="login.html">登录</a></li>
            <li><a href="register.html">注册</a></li>
        </ul>
    </nav>

    <div class="register-container">
        <div class="register-form">
            <h2>用户注册</h2>
            <form id="registerForm">
                <div class="form-group">
                    <label for="username">用户名</label>
                    <input type="text" id="username" name="username" required>
                    <div class="error-message" id="usernameError">用户名必须为3-20个字符，只能包含字母、数字和下划线</div>
                </div>

                <div class="form-group">
                    <label for="email">电子邮箱</label>
                    <input type="email" id="email" name="email" required>
                    <div class="error-message" id="emailError">请输入有效的电子邮箱地址</div>
                </div>

                <div class="form-group">
                    <label for="password">密码</label>
                    <input type="password" id="password" name="password" required>
                    <div class="password-strength">
                        <div class="password-strength-bar" id="passwordStrengthBar"></div>
                    </div>
                    <div class="password-strength-text" id="passwordStrengthText">密码强度: 弱</div>
                    <div class="error-message" id="passwordError">密码必须至少8个字符，包含字母和数字</div>
                </div>

                <div class="form-group">
                    <label for="confirmPassword">确认密码</label>
                    <input type="password" id="confirmPassword" name="confirmPassword" required>
                    <div class="error-message" id="confirmPasswordError">两次输入的密码不一致</div>
                </div>

                <div class="form-group">
                    <label>
                        <input type="checkbox" name="terms" id="terms" style="width: auto; margin-right: 5px;" required>
                        我同意<a href="#" style="color: #ff0066;">服务条款</a>和<a href="#" style="color: #ff0066;">隐私政策</a>
                    </label>
                    <div class="error-message" id="termsError">必须同意服务条款和隐私政策</div>
                </div>

                <button type="submit" class="register-btn">注册</button>

                <div class="form-footer">
                    <p>已有账户？<a href="login.html">立即登录</a></p>
                </div>
            </form>
        </div>

        <div class="register-info">
            <h3>为什么加入代码狂想？</h3>
            <p>成为代码狂想社区的一员，享受更多专属功能：</p>

            <div class="feature-list">
                <div class="feature-item">
                    <div class="feature-icon">1</div>
                    <span>保存和收藏技术文章</span>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">2</div>
                    <span>参与技术讨论和评论</span>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">3</div>
                    <span>获取个性化内容推荐</span>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">4</div>
                    <span>订阅技术主题更新</span>
                </div>
                <div class="feature-item">
                    <div class="feature-icon">5</div>
                    <span>下载技术资源</span>
                </div>
            </div>

            <div class="brutal-element"></div>

            <h3>社区统计</h3>
            <ul>
                <li>超过 10,000 名注册开发者</li>
                <li>500+ 深度技术文章</li>
                <li>活跃的技术讨论社区</li>
                <li>每月新增 50+ 技术内容</li>
            </ul>

            <div class="brutal-element"></div>

            <h3>注册须知</h3>
            <p>注册即表示您同意我们的服务条款和隐私政策。我们承诺保护您的个人信息安全，不会与第三方共享您的数据。</p>
        </div>
    </div>

    <footer>
        <p>代码狂想 &copy; 2023 · 遵循野蛮主义设计原则构建</p>
        <p>联系方式: contact@codecraze.blog</p>
    </footer>

    <script>
        // 表单验证逻辑
        document.getElementById('registerForm').addEventListener('submit', function (e) {
            e.preventDefault();

            let isValid = true;
            const username = document.getElementById('username').value.trim();
            const email = document.getElementById('email').value.trim();
            const password = document.getElementById('password').value;
            const confirmPassword = document.getElementById('confirmPassword').value;
            const terms = document.getElementById('terms').checked;

            // 验证用户名
            const usernameRegex = /^[a-zA-Z0-9_]{3,20}$/;
            if (!usernameRegex.test(username)) {
                document.getElementById('usernameError').style.display = 'block';
                isValid = false;
            } else {
                document.getElementById('usernameError').style.display = 'none';
            }

            // 验证邮箱
            const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
            if (!emailRegex.test(email)) {
                document.getElementById('emailError').style.display = 'block';
                isValid = false;
            } else {
                document.getElementById('emailError').style.display = 'none';
            }

            // 验证密码
            const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/;
            if (!passwordRegex.test(password)) {
                document.getElementById('passwordError').style.display = 'block';
                isValid = false;
            } else {
                document.getElementById('passwordError').style.display = 'none';
            }

            // 验证确认密码
            if (password !== confirmPassword) {
                document.getElementById('confirmPasswordError').style.display = 'block';
                isValid = false;
            } else {
                document.getElementById('confirmPasswordError').style.display = 'none';
            }

            // 验证服务条款
            if (!terms) {
                document.getElementById('termsError').style.display = 'block';
                isValid = false;
            } else {
                document.getElementById('termsError').style.display = 'none';
            }

            if (isValid) {
                // 这里可以添加实际的注册逻辑
                alert('注册成功！');
                // 实际应用中应该重定向到登录页面或用户主页
                // window.location.href = 'login.html';
            }
        });

        // 实时验证输入
        document.getElementById('username').addEventListener('input', function () {
            const usernameRegex = /^[a-zA-Z0-9_]{3,20}$/;
            if (usernameRegex.test(this.value.trim())) {
                document.getElementById('usernameError').style.display = 'none';
            }
        });

        document.getElementById('email').addEventListener('input', function () {
            const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
            if (emailRegex.test(this.value.trim())) {
                document.getElementById('emailError').style.display = 'none';
            }
        });

        document.getElementById('password').addEventListener('input', function () {
            const password = this.value;
            const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$/;

            // 密码强度指示器
            let strength = 0;
            const strengthBar = document.getElementById('passwordStrengthBar');
            const strengthText = document.getElementById('passwordStrengthText');

            if (password.length >= 8) strength += 25;
            if (/[a-z]/.test(password)) strength += 25;
            if (/[A-Z]/.test(password)) strength += 25;
            if (/[0-9]/.test(password)) strength += 25;

            strengthBar.style.width = strength + '%';

            if (strength < 50) {
                strengthBar.style.backgroundColor = '#ff0066';
                strengthText.textContent = '密码强度: 弱';
            } else if (strength < 75) {
                strengthBar.style.backgroundColor = '#ffaa00';
                strengthText.textContent = '密码强度: 中';
            } else {
                strengthBar.style.backgroundColor = '#00cc66';
                strengthText.textContent = '密码强度: 强';
            }

            if (passwordRegex.test(password)) {
                document.getElementById('passwordError').style.display = 'none';
            }
        });

        document.getElementById('confirmPassword').addEventListener('input', function () {
            const password = document.getElementById('password').value;
            if (this.value === password) {
                document.getElementById('confirmPasswordError').style.display = 'none';
            }
        });

        document.getElementById('terms').addEventListener('change', function () {
            if (this.checked) {
                document.getElementById('termsError').style.display = 'none';
            }
        });
    </script>
</body>

</html>